import { VxeUI } from "vxe-pc-ui";
import EnumValueDownModal from "./EnumValueDownModal.vue";
import TypingValueBwModal from "./TypingValueBwModal.vue";
import { ElInput } from "element-plus";
import { BSDataTypeEnum, RecordTypeEnum } from "@@/constants/other-keys";

// 创建一个复杂的组合渲染
VxeUI.renderer.add("EnumValueDownModal", {
  tableAutoFocus: "input",
  renderTableDefault(renderOpts, params) {
    const { row, column } = params
    let renderInner: any = "类不可编辑";
    if (row.type === BSDataTypeEnum.Base) {
      renderInner = <ElInput v-model={row[column.field]} />;
    }
    if (row.type === BSDataTypeEnum.Enum) {
      if (row.recordType == RecordTypeEnum.Base) {
        renderInner = (
          <EnumValueDownModal
            params={params}
            renderOpts={renderOpts}
          ></EnumValueDownModal>
        );
      } else {
        renderInner = (
          <TypingValueBwModal
            params={params}
            renderOpts={renderOpts}
          ></TypingValueBwModal>
        );
      }
    }
    return renderInner;
  },
});
